package com.why.serviceedu.controller;


import com.why.commonresults.Result;
import com.why.serviceedu.bean.oneSubject;
import com.why.serviceedu.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author why
 * @since 2021-01-31
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class EduSubjectController {
    @Autowired
    private EduSubjectService service;

    /**
     * 获取上传的文件进行读取
     *
     * @return
     */
    @PostMapping("/addSubject")
    public Result addSubject(MultipartFile file) {

        service.savSubject(file, service);
        return Result.ok();
    }

    /**
     * 课程分类，树形，一级分类下面有二级分类
     * @return
     */

    @GetMapping("/getAllSubject")
    public Result getAllSubject() {

        List<oneSubject> subjectList = service.getOneAndTwoSubject();

        return Result.ok().data("list",subjectList);
    }

}

